home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / comm / tcp / hserv.lha / hserv / temp / QuickStart.rexx < prev    next >
OS/2 REXX Batch file  |  1999-05-24  |  3KB  |  111 lines

  1. /* QuickStart/10.1 - Quick start for hserv */
  2.  
  3. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  4. if AddLibrary("rexxsupport.library","rxsocket.library","rxwiz.library")~=0 then exit
  5.  
  6. if ~IsLibOn("SOCKET") then do
  7.     call EasyRequest("No TCP/IP stack is running."d2c(10)"A bsdsocket.library compatible"d2c(10)"internet stack must be started"d2c(10)"before you can run hserv.")
  8.     exit
  9. end
  10.  
  11. global.cat="quickstart.catalog"
  12.  
  13. call pragma("D",PathPart(ProgramName("FULL")))
  14. s.snapshot=1
  15. s.catalog=global.cat
  16. res=OpenSurface("QuickStart.wizard","S")
  17. if res~=0 then exit
  18. w.ID=1
  19. w.Gads=16
  20. res=OpenWindow("S","W")
  21. say res
  22. if res~=0 then exit
  23. global.ws=WindowSignal("S","W")
  24.  
  25. global.file="/conf/hserv.conf"
  26. global.port=80
  27. call getStrings
  28. global.0=global.str.CANTFIND
  29. global.1=global.str.RUNNING
  30. global.2=global.str.NOSERVER
  31. global.status=""
  32. call setGadgets
  33.  
  34. stop=0
  35. ctrl_c=2**12
  36. swait=or(global.ws,ctrl_c)
  37. do while ~stop
  38.     srec=Wait(swait,1)
  39.     if and(srec,ctrl_c)~=0 then call break_c
  40.     if and(srec,global.ws)~=0 then stop=handleObj("W")
  41.     if ~stop then call setGadgets
  42. end
  43. exit
  44. /**************************************************************************/
  45. handleObj: procedure expose global.
  46. parse arg o
  47.     handle.wait=0
  48.     res=HandleWindow("S",o,"HANDLE")
  49.     if res~=0 then exit
  50.     if handle.imsg>0 then
  51.         do i=0 to handle.imsg-1
  52.             select
  53.                 when handle.i.class="CLOSEWINDOW" then return 1
  54.                 when handle.i.class="VANILLAKEY" then call GadgetKey("S",o,handle.i.code,handle.i.QUALIFIER)
  55.                 when handle.i.class="IDCMPUPDATE" then
  56.                         if handle.i.ObjectID~="" & handle.i.config~="" then
  57.                             interpret handle.i.config
  58.                 otherwise nop
  59.             end
  60.         end
  61.     return 0
  62. /**************************************************************************/
  63. checkServ: procedure /* -1:busy 0:running 1:free */
  64. parse arg port
  65.     if checkPort(port) then return 0
  66.     s=socket("INET","STREAM")
  67.     sin.addrPort=port
  68.     res=bind(s,"SIN")
  69.     call CloseSocket(s)
  70.     if res=0 then res=1
  71.     return res
  72. /**************************************************************************/
  73. checkPort: procedure
  74. parse arg port
  75.     return show("P","HSERV."port)
  76. /**************************************************************************/
  77. setGadgets: procedure expose global.
  78.     n="HCONF_HSERV."global.port
  79.     t=GetClip(n)
  80.     show=(t~="")
  81.     d=checkServ(global.port)
  82.     if global.status=d then do
  83.         set.disabled = ((d~=0) | show)
  84.         call SetWizAttrs("S","W","SHOW","SET")
  85.         return
  86.     end
  87.     global.status=d
  88.     set.disabled = (d~=1)
  89.     call SetWizAttrs("S","W","START","SET")
  90.     call SetWizAttrs("S","W","FILE","SET")
  91.     set.disabled = (d~=0)
  92.     call SetWizAttrs("S","W","REMOVE","SET")
  93.     set.disabled = ((d~=0) | show)
  94.     call SetWizAttrs("S","W","SHOW","SET")
  95.     drop set.
  96.     i=d+1
  97.     set.text = global.i
  98.     call SetWizAttrs("S","W","INFO","SET")
  99.     global.lastInfo=set.text
  100.     return
  101. /**************************************************************************/
  102. getStrings: procedure expose global.
  103.     catalog=OpenCatalog(global.cat,"english",0)
  104.     global.str.CANTFIND=GetCatalogStr(catalog,1000,"Can't bind")
  105.     global.str.RUNNING=GetCatalogStr(catalog,1001,"Running")
  106.     global.str.NOSERVER=GetCatalogStr(catalog,1002,"No server")
  107.     call CloseCatalog(catalog);
  108.     return
  109. /**************************************************************************/
  110. /*$VER: QuickStart.rexx 12.1 (14.5.99)*/
  111.